package JPetStore.service;

import JPetStore.domain.Account;
import JPetStore.persistence.AccountDao;
import JPetStore.persistence.impl.AccountDaoImpl;

public class AccountService {

    private AccountDao accountDAO = new AccountDaoImpl();
    private AccountDao accountDao;

    public AccountService(){
        this.accountDao = new AccountDaoImpl();
    }

    public Account getAccount(String username, String password) {
        Account account = new Account();
        account.setUsername(username);
        account.setPassword(password);
        return accountDao.getAccountByUsernameAndPassword(account);
    }


    public int changeInformation(Account account) {
        return this.accountDAO.changeInformation(account);
    }

    public boolean is_repeat(String username) {
        return this.accountDAO.is_repeat(username);
    }

    public boolean is_exist(String username, String password) {
        return this.accountDAO.is_exist(username, password);
    }

    public int addAccount(Account account) {
        return this.accountDAO.addAccount(account);
    }

    public int addSignOn(Account account) {
        return this.accountDAO.addSignOn(account);
    }

    public Account getAccountByUsername(String username) {
        return this.accountDAO.getAccountByUsername(username);
    }

    public int changePassword(String username, String password) {
        return this.accountDAO.changePassword(username, password);
    }

    public int changeUsername(String newusername, String username) {
        return this.accountDAO.changeUsername(newusername, username);
    }

}
